#ifndef UICONTROL_H
#define UICONTROL_H
#include <QObject>
#include "socketserver.h"


class UiControl : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QString doorNo READ doorNo WRITE setDoorNo NOTIFY DoorNoRewrite)
    Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY IntervalRewrite)

public:
    explicit UiControl(QObject *parent = nullptr);
    virtual ~UiControl();
    void initUI();

    void setDoorNo(const QString &value){
        if(value!=m_doorNo){
            m_doorNo=value;
            emit DoorNoRewrite();
        }
    }
    QString doorNo() const {
        return m_doorNo;
    }

    void setInterval(const int &value){
        if(value!=m_interval){
            m_interval=value;
            emit IntervalRewrite();
        }
    }
    int interval() const {
        return m_interval;
    }

private:
    SocketServer *sock_server;
    QString m_doorNo;
    int m_interval;

    QString readFile(const QString &path);
    void defaultBackground();


signals:
    void DoorNoRewrite();
    void IntervalRewrite();
    void PicRewrite(QString);
    void QrcodeRewrite(QString);


public slots:
    void onDoorNoChanged();
    void onPicChanged();
    void onQrCodeChanged();
    void onIntervalChanged();
};

#endif // UICONTROL_H
